<?php
/**
 * @filesource modules/event/controllers/IndexController.php
 * @author Hoang
 * @abstract : List of actions in order
 *   - new
 *   - view
 *   - edit
 *   - delete
 *   - search
 */ 
class Hvn_MasterController extends Clu_Controller_Action_Master
{
	public $m,$c;//, $mPlace, $mArticle;
	public $tl;
	public function init()
	{
//		include (APP_PATH.'/modules/place/Model/Place.php');
//		include (APP_PATH.'/modules/event/Model/Event.php');
//		include (APP_PATH.'/modules/category/Model/Category.php');
		//require_once (APP_PATH.'/modules/tour/Model/Tour.php');
//		//require_once (APP_PATH.'/modules/user/Model/User.php');
//		//require_once (APP_PATH.'/modules/tour/Model/TLeg.php');
//		$this->mArticle = new article_Model_Service();
//		$this->m = new Model_Tour();
		//$this->c = new category_Model_Category();
//		$this->tl = new Model_TLeg();
		$this->mPlace = new place_Model_Place();
		$this->mEvent = new event_Model_Service();
//		$this->mTour  = new Model_Tour();
 		
		parent::init();
		
	}
	
	public function homeAction()
	{
		$sess = new Zend_Session_Namespace(CLU_NS);
		$this->paramsForWidgets['template'] = 'home';
		$this->paramsForWidgets['region'] = 5;
		$this->paramsForWidgets['weight'] = 1;
	}
	
	public function aboutVietnam()
	{
//		$this->paramsForWidgets = array('param1' => $this->mPlace
//										);
		
	}
	public function getListCities($data)
	{
		$select = $this->mPlace->search($data);
		$paginator = $this->generatePaginator($select, 1, 10, 5, 'Jumping');
				
      	//cache in $_SESSION
       	$sess = new Zend_Session_Namespace("paginator");
       	$sess->place_admin = array("search_params" => $data);
        $data = $sess->place_admin;
        if(isset($data))
        {
    		$select = $this->mPlace->search($data['search_params']);
       		$paginator = $this->generatePaginator($select, $this->_getParam('page'), 10,5, 'Jumping');
        }
        return $paginator;
	}
	
	public function getListEvent($data)
	{
	   	$select = $this->mEvent->search($data);
	   	$paginator = $this->generatePaginator($select, 1, 10, 5, 'Jumping');
	   	$sess = new Zend_Session_Namespace("paginatorEvent");
	   	$sess->event_admin = array("event_params" => $data);
        $data = $sess->event_admin;
				
      	//cache in $_SESSION
        if(isset($data))
        {
   			$select = $this->mEvent->search($data['event_params']);
       		$paginator = $this->generatePaginator($select, $this->_getParam('page'), 10,5, 'Jumping');
        }
        return $paginator;
	}
	
	public function getListTour($data)
	{
		$select = $this->mTour->search($data);
	   	$paginator = $this->generatePaginator($select, 1, 10, 5, 'Jumping');
	   	$sess = new Zend_Session_Namespace("paginatorTour");
	   	$sess->tour_admin = array("tour_params" => $data);
        $data = $sess->tour_admin;
				
      	//cache in $_SESSION
        if(isset($data))
        {
   			$select = $this->mTour->search($data['tour_params']);
       		$paginator = $this->generatePaginator($select, $this->_getParam('page'), 10,5, 'Jumping');
        }
        return $paginator;	
	}
	
	/*
	public function generatePaginator($select, $pageNumber, $itemsPerPage, $pageRange, $style)
    {
		$paginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbSelect($select));
		$paginator->setItemCountPerPage($itemsPerPage);
		$paginator->setCurrentPageNumber($pageNumber);
		$paginator->setPageRange($pageRange);
		Zend_Paginator::setDefaultScrollingStyle($style);
		return $paginator;
    }
    */
}
?>
